#!/bin/sh
#
# notify -- Start any cmd in a container
#
# Copyright (C) 2016-2021 Wu Zhangjin <falcon@ruma.tech>
#

TOP_DIR="$(cd "$(dirname "$0")"/../../ && pwd)"
. "$TOP_DIR"/tools/docker/config >/dev/null

[ -z "$1" ] && echo "Usage: $0 [lab-name] msg" && exit 0

msg=$1
[ -n "$2" ] && msg=$2

cmd="//bin/bash -c 'export DISPLAY=:1 && notify-send -u critical -t 0 "
cmd="$cmd \"$msg\""
cmd="$cmd '"

lab_id=$(docker ps -f name=$CONTAINER_NAME -f status=running -q)
[ -z "$lab_id" ] && err_print "$LAB_NAME is not running." && exit 1

do_op "docker exec" CONTAINER_NAME "$cmd"
